﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Bbm.Persistence
{
	public class MemoryHog : IPhysicalStoreFactory
	{
		readonly Dictionary<string, IDictionary<string, string>> stores = new Dictionary<string, IDictionary<string, string>>();

		/// <summary>
		///  Returns a physical store for the given storage name. Name uniqueness
		///  is provided by the caller.
		///  </summary>
		/// <param name="name">
		///   The name of the store
		/// </param>
		/// <returns>
		///  A PhysicalStoreBase object the allows persistent storage
		///  </returns>
		public IDictionary<string, string> GetStoreForName(CacheStoreName name)
		{
			lock(stores)
			{
				if(!stores.ContainsKey(name.ToString()))
					stores.Add(name.ToString(), new Dictionary<string, string>());

				return stores[name.ToString()];
			}
		}
	}
}
